package sz.szsmk.citizencard.util;

import android.graphics.Color;
import android.os.CountDownTimer;
import android.widget.Button;

import sz.szsmk.citizencard.DaggerApplication;
import sz.szsmk.citizencard.R;

/**
 * Copyright (c)2018
 * author: zdh
 * created on: 2018/6/7 9:21
 * description:
 */
public class TimeCount extends CountDownTimer {
    private Button mView;

    public TimeCount(Button view, long millisInFuture, long countDownInterval) {
        super(millisInFuture, countDownInterval);
        mView = view;
    }

    @Override
    public void onTick(long millisUntilFinished) {
        mView.setBackgroundColor(Color.parseColor("#00ffffff"));
        mView.setClickable(false);
        mView.setTextColor(DaggerApplication.getIns().getResources().getColor(R.color.color_translucent_ee));
        mView.setText("重新发送("+millisUntilFinished / 1000 +")");
    }

    @Override
    public void onFinish() {
        mView.setText("重新发送");

        mView.setClickable(true);

        mView.setTextColor(DaggerApplication.getIns().getResources().getColor(R.color.color_00AAFF));
        mView.setBackgroundColor(Color.parseColor("#00ffffff"));
//        mView.setBackgroundColor(Color.parseColor("#4EB84A"));
    }
}
